package com.tenglong.teacher.ui.utils;

import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Build;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;

import com.tenglong.teacher.R;

/**
 * @author hdx on 2019/4/25.
 */
public class MyPreference extends DialogPreference {
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public MyPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public MyPreference(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public MyPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public MyPreference(Context context) {
        super(context);
    }

    @Override
    protected void onBindView (View view) {
        super.onBindView(view);
        view.setOnClickListener(null);
        view.findViewById(R.id.action_button1).setOnClickListener(mListener);
    }

    @Override
    protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
        super.onPrepareDialogBuilder(builder);
    }

    private View.OnClickListener mListener = null;
    public void setOnClickListener(View.OnClickListener listener) {
        mListener = listener;
    }
}
